﻿CREATE procedure [dbo].[FC_Forecast_Read]
@IdCustomer int,
@IdProduct int

as
begin
	select F.IdUsuario, F.IdCustomer, SE.IdSegmentPL, F.IdProduct, PU.DesUOM, CU.Codigo AS CodCliente
	from FC_Forecast F 
		LEFT JOIN FC_Product PR ON F.IdProduct = PR.IdProduct
		LEFT JOIN FC_SegmentPL SE ON SE.IdSegmentPL = PR.IdSegmentPL	 
		LEFT JOIN FC_UOM PU ON PR.IdUOM = PU.IdUOM
		LEFT JOIN FC_Customer CU ON F.IdCustomer = CU.IdCustomer
	where F.IdProduct = @IdProduct AND F.IdCustomer = @IdCustomer
	group by F.IdUsuario, F.IdCustomer, SE.IdSegmentPL, F.IdProduct, PU.DesUOM, CU.Codigo
end